package blip.jcaf.cm;

import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Map;

import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.map.ObjectMapper;

public class RestClient {

	public static Map<String, Object> connect(String theUrl) throws IOException {

		URL url = new URL(theUrl);
		URLConnection connection = url.openConnection();
		connection.setDoInput(true);
		ObjectMapper mapper = new ObjectMapper();
		mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
		@SuppressWarnings("unchecked")
		Map<String,Object> response = mapper.readValue(connection.getInputStream(), Map.class);
		return response;
	}

}